package com.wsr.fei.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class MyTool{
	public static boolean isEMail(String email){
		String str="^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$";
        Pattern p = Pattern.compile(str);     
        Matcher m = p.matcher(email);     
        return m.matches(); 
	}
	
	
	 public static boolean isMobileNO(String mobiles){     
	        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");     
	        Matcher m = p.matcher(mobiles);     
	        return m.matches();     
	    }
	 
	 
	 public static boolean isPwdLenOK(String password){
		 if((password.trim().length()>=6) && (password.trim().length()<=20)){
			 return true;
		 }
		 
		 return false;
			 
	 }
	 
	
	
	 
	 public static void saveLoginInfo(Context context,String email,String password){
	        SharedPreferences sharedPre=context.getSharedPreferences(FeiValue.SP_NAME, context.MODE_PRIVATE);
	        Editor editor=sharedPre.edit();
	        editor.putString(FeiValue.SP_EMAIL, email);
	        editor.putString(FeiValue.SP_PASSWORD, password);
	        editor.putBoolean(FeiValue.SP_ISLOGIN, true);
	    
	        editor.commit();
	    }
	 
	 public static void quitLogin(Context context){
		 	SharedPreferences sharedPre=context.getSharedPreferences(FeiValue.SP_NAME, context.MODE_PRIVATE);
	        Editor editor=sharedPre.edit();
	        editor.putString(FeiValue.SP_EMAIL, "");
	        editor.putString(FeiValue.SP_PASSWORD, "");
	        editor.putBoolean(FeiValue.SP_ISLOGIN, false);
	    
	        editor.commit();
	 }
}
